package cn.lanqiao.springboot.service;

import cn.lanqiao.springboot.entity.User;
import cn.lanqiao.springboot.mapper.UserMapper;
import cn.lanqiao.springboot.vo.QueryUserVO;
import cn.lanqiao.springboot.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserService {

    @Autowired
    UserMapper userMapper;

//    String salt = "#abc$789@";

    public List<User> getAllUsers(QueryUserVO queryUserVO) {
        // 这里可以调用 UserMapper 来获取用户数据
        return userMapper.selectAllUsers(queryUserVO);
    }

    public void insertUser(User user) {
        user.setCreateTime(new Date());
        userMapper.insertUser(user);
    }

    public void deleteUser(Integer userId) {
        userMapper.deleteUser(userId);
    }

    public void updateUser(User user) {
        userMapper.updateUser(user);
    }

    public UserVO checkUser(User user) {
//        user.setPassword(MD5Util.getMD5(user.getPassword()+salt));
        return userMapper.checkUser(user);
    }
}
